class Solution:
    def hammingWeight(self, n: int) -> int:
        DIGIT = 32
        ans = 0
        mask = 1
        for i in range(DIGIT):
            mask = 1 << i
            res = mask & n
            if res == mask:
                ans += 1
        return ans
